//by hbs
#include <bits/stdc++.h>
using namespace std;

#define N 200010

int n,a[N],ans;
bool flag[N];

inline int rd()
{
    register int f=1,m=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        m=(m<<3)+(m<<1)+(ch^48);
        ch=getchar();
    }
    return f*m;
}

int count()
{
    int cnt=0;
    for(int i=n;i>0;--i)
    {
        for(int j=i-1;j>0;--j)
        {
            if(flag[i]==flag[j])
            {
                if(a[i]==a[j])
                    cnt+=a[i];
                break;
            }
        }
    }
    return cnt;
}

void operation(int pos)
{
    if(pos>n)
    {
        ans=max(ans,count());
        return;
    }
    flag[pos]=0;
    operation(pos+1);
    flag[pos]=1;
    operation(pos+1);
}

int main()
{
    //remember to clear when the number is removed
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int T=rd();
    for(int t=1;t<=T;++t)
    {
        n=rd();
        ans=0;
        for(int i=1;i<=n;++i)
            a[i]=rd();
        operation(1);
        printf("%d\n",ans);
    }
    return 0;
}